package jtk.project4.fleet.field;

import java.awt.Dimension;

import jtk.project4.fleet.action.AddEmployeeAction;

import nl.coderight.jazz.action.Action;
import nl.coderight.jazz.form.FormLayout;
import nl.coderight.jazz.form.control.CalendarControl;
import nl.coderight.jazz.form.control.GroupControl;
import nl.coderight.jazz.form.field.ComboField;
import nl.coderight.jazz.form.field.TextField;
import nl.coderight.jazz.form.field.button.PushButton;

public class NewEquipmentAssignmentField extends GroupControl{
	private ComboField locationField;
	private ComboField categoryField;
	private ComboField driverField;
	private ComboField costCenterField;
	private PushButton addEmployeeField;
	private Action addEmployeeAction;
	
	
	
	public NewEquipmentAssignmentField(String bindID){
		setTitle("header.Assignment");
		setBindID(bindID);
		addEmployeeAction = new AddEmployeeAction();
		createFields();
		createLayout();
	}
	
	private void createFields(){
		
		locationField = new ComboField("equipments","location");
		locationField.setPreferredSize(new Dimension(160, 20));
		categoryField = new ComboField("equipments","category");
		categoryField.setPreferredSize(new Dimension(160, 20));
		driverField = new ComboField("equipments","driver");
		driverField.setPreferredSize(new Dimension(130, 20));
		costCenterField = new ComboField("equipments","coscenter");
		costCenterField.setPreferredSize(new Dimension(160, 20));
		addEmployeeField = new PushButton(addEmployeeAction);
		addEmployeeField.setPreferredSize(new Dimension(30, 20));
		
		
	}
	
	private void createLayout() {
		setLayout(new FormLayout())
		.addLabel("Location:")		.addField(locationField)
		.addRow()
		.addLabel("Category:").addField(categoryField)
		.addRow()
		.addLabel("Driver:").addField(createInsideField())
		
		.addRow()
		.addLabel("Cost Center:").addField(costCenterField);
	}
	
	private GroupControl createInsideField() {
		GroupControl form = new GroupControl();
		form.setLayout(new FormLayout());
		form.addField(driverField);
		form.addField(addEmployeeField);
		return form;
	}
}
